import java.util.concurrent.CountDownLatch;

public class MultiplyThread extends Thread {
    private double[][] m;
    private double[][] n;
    private int startRow;
    private CountDownLatch latch;
    private double[][] result;
    //private long runTime;
    MultiplyThread(double[][] matrix1, double[][] matrix2, int startRow, CountDownLatch latch){
        m = matrix1;
        n = matrix2;
        result = new double[matrix1.length][matrix2[0].length];
        this.startRow = startRow;
        this.latch = latch;
    }
    @Override
    public void run(){
        for (int i = startRow; i < m.length; i=i+2) {
            //隔一行算
            for (int j = 0; j < n[0].length; j++) {

                result[i][j] = 0.0;
                for (int k = 0; k < n.length; k++) {
                    result [i][j] += m[i][k] * n[k][j];
                }

            }
        }
        latch.countDown();
    }

    public double[][] getResult() {
        return result;
    }
}
